Neural Style Transfer

Xinzhu Wang(xw2581), Ying Jin(yj2453), Jincheng Xu(jx2365), Xudong Guo(xg2305)

In [0]:
import os
import numpy as np
import scipy.io
import imageio
import tensorflow as tf
import matplotlib.pyplot as plt
import random
from google.colab import files
from PIL import Image, ImageOps
import cv2
#import necessary packages

The default version of TensorFlow in Colab will soon switch to TensorFlow 2.x.
We recommend you upgrade now or ensure your notebook will continue to use TensorFlow 1.x via the %tensorflow_version 1.x magic: more info.

In [0]:
print("TF version: ",tf.__version__)
TF version:  1.15.0
In [0]:
from google.colab import drive
drive.mount('/content/drive')
Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly

Enter your authorization code:
··········
Mounted at /content/drive

Preprocessing

In [0]:
def resize_image(image_path, width, height, save = True):
  image = Image.open(image_path)
  image = ImageOps.fit(image, (width, height), Image.ANTIALIAS)
  if save:
    image_directory = image_path.split('/')
    image_directory[-1] = 'resized_' + image_directory[-1]
    output_path = '/'.join(image_directory)
    if not os.path.exists(output_path):
      image.save(output_path)
  image = np.asarray(image, np.float32)
  return np.expand_dims(image, 0)
#define resize image function
In [0]:
def noise_image(content_image, width, height, noise_ratio = 0.6):
  noise_image = np.random.uniform(-20, 20, (1, height, width, 3)).astype(np.float32)
  aggregated = noise_image * noise_ratio + content_image * (1 - noise_ratio)
  return aggregated
#define noise image function
In [0]:
def preprocess(content_image_path,style_image_path):

    content_image = resize_image(content_image_path, image_width, image_height)
    style_image = resize_image(style_image_path, image_width, image_height)

    noise_images = noise_image(content_image, image_width, image_height)

    style_image -= MEAN_PIXEL
    content_image -= MEAN_PIXEL

    return style_image, content_image, noise_images
#define preprocess function
In [0]:
def inp(image_widths, image_heights):
    with tf.variable_scope("input"):
        input_img = tf.get_variable("in_img", 
                                    shape = ([1, image_heights, image_widths, 3]),
                                    dtype = tf.float32,
                                    initializer = tf.zeros_initializer())
    return input_img
#define input_image function

Load VGG19 model

In [0]:
VGG19 = scipy.io.loadmat('drive/My Drive/5242_project/imagenet-vgg-verydeep-19.mat')
In [0]:
vgg_layer = VGG19['layers']
In [0]:
def weights(layer, expected_layer_name):
    # Return the weights and bias from VGG for a given layer
    weight = vgg_layer[0][layer][0][0][2][0][0] # (3,3,3,64)
    bias = vgg_layer[0][layer][0][0][2][0][1] # (64,1)
    layer_name = vgg_layer[0][layer][0][0][0][0] #current layer name
    assert layer_name == expected_layer_name, print(expected_layer_name, layer_name)
    return weight, bias
In [0]:
def conv_relu(previous_layer, current_layer, layer_name):
    w, b = weights(current_layer, layer_name)
    W = tf.constant(w)
    B = tf.constant(np.reshape(b, b.size)) # 64
    conv = tf.nn.conv2d(previous_layer, filters=W, strides=[1,1,1,1], padding='SAME')
    return tf.nn.relu(conv + B)
In [0]:
def avg_pool(previous_layer):
    return tf.nn.avg_pool(previous_layer, ksize=[1,2,2,1],strides=[1,2,2,1],padding='SAME')
In [0]:
layers = (
        'conv1_1', 'relu1_1', 'conv1_2', 'relu1_2', 'pool1',

        'conv2_1', 'relu2_1', 'conv2_2', 'relu2_2', 'pool2',

        'conv3_1', 'relu3_1', 'conv3_2', 'relu3_2', 'conv3_3',
        'relu3_3', 'conv3_4', 'relu3_4', 'pool3',

        'conv4_1', 'relu4_1', 'conv4_2', 'relu4_2', 'conv4_3',
        'relu4_3', 'conv4_4', 'relu4_4', 'pool4',

        'conv5_1', 'relu5_1', 'conv5_2', 'relu5_2', 'conv5_3',
        'relu5_3', 'conv5_4', 'relu5_4'
    )
In [0]:
def vgg_model(inputs):
    vgg = {}
    layer_dict = {}
    for layer_idx,layer_name in enumerate(layers):
        layer_dict[layer_name]=layer_idx
        
    vgg['input'] = inputs
    vgg['conv1_1']=conv_relu(vgg['input'],layer_dict['conv1_1'],'conv1_1')
    vgg['conv1_2']=conv_relu(vgg['conv1_1'],layer_dict['conv1_2'],'conv1_2')
    vgg['avgpool1']=avg_pool(vgg['conv1_2'])
    vgg['conv2_1']=conv_relu(vgg['avgpool1'],layer_dict['conv2_1'],'conv2_1')
    vgg['conv2_2']=conv_relu(vgg['conv2_1'],layer_dict['conv2_2'],'conv2_2')
    vgg['avgpool2']=avg_pool(vgg['conv2_2'])
    vgg['conv3_1']=conv_relu(vgg['avgpool2'],layer_dict['conv3_1'],'conv3_1')
    vgg['conv3_2']=conv_relu(vgg['conv3_1'],layer_dict['conv3_2'],'conv3_2')
    vgg['conv3_3']=conv_relu(vgg['conv3_2'],layer_dict['conv3_3'],'conv3_3')
    vgg['conv3_4']=conv_relu(vgg['conv3_3'],layer_dict['conv3_4'],'conv3_4')
    vgg['avgpool3']=avg_pool(vgg['conv3_4'])
    vgg['conv4_1']=conv_relu(vgg['avgpool3'],layer_dict['conv4_1'],'conv4_1')
    vgg['conv4_2']=conv_relu(vgg['conv4_1'],layer_dict['conv4_2'],'conv4_2')
    vgg['conv4_3']=conv_relu(vgg['conv4_2'],layer_dict['conv4_3'],'conv4_3')
    vgg['conv4_4']=conv_relu(vgg['conv4_3'],layer_dict['conv4_4'],'conv4_4')
    vgg['avgpool4']=avg_pool(vgg['conv4_4'])
    vgg['conv5_1']=conv_relu(vgg['avgpool4'],layer_dict['conv5_1'],'conv5_1')
    vgg['conv5_2']=conv_relu(vgg['conv5_1'],layer_dict['conv5_2'],'conv5_2')
    vgg['conv5_3']=conv_relu(vgg['conv5_2'],layer_dict['conv5_3'],'conv5_3')
    vgg['conv5_4']=conv_relu(vgg['conv5_3'],layer_dict['conv5_4'],'conv5_4')
    vgg['avgpool5']=avg_pool(vgg['conv5_4'])

    return vgg
#define vgg19 model

Loss Function

In [0]:
content_layer = "conv4_2"
style_layers = ["conv1_1", "conv2_1", "conv3_1", "conv4_1", "conv5_1"]
In [0]:
def _content_loss(P, F):     
    content_loss = tf.reduce_sum(tf.square(F - P)) / 2
    return content_loss
In [0]:
def _gram_matrix(F, N, M):
    F = tf.reshape(F, (M, N))
    return tf.matmul(tf.transpose(F), F)
In [0]:
def _single_style_loss(a, g):    
    N = a.shape[3]
    M = a.shape[1] * a.shape[2]
    A = _gram_matrix(a, N, M)
    G = _gram_matrix(g, N, M)
    return tf.reduce_sum(tf.square(G - A)) / ((2 * N * M) ** 2)
In [0]:
def _style_loss(A):
    n_layers = len(A)
    E = [_single_style_loss(A[i], vgg[style_layers[i]]) for i in range(n_layers)]
    style_loss = sum(style_layers_weights[i] * E[i] for i in range(n_layers))
    return style_loss
In [0]:
def losses():
    with tf.variable_scope("losses"):
        with tf.Session() as sess:
            sess.run(tf.global_variables_initializer())
            sess.run(input_img.assign(content_image))
            gen_img_content = vgg[content_layer]
            content_img_content = sess.run(gen_img_content)
            content_loss = _content_loss(content_img_content, gen_img_content)

        with tf.Session() as sess:
            sess.run(input_img.assign(style_image))
            new_style_layers = sess.run([vgg[layer] for layer in style_layers])                              
        style_loss = _style_loss(new_style_layers)

        total_loss = content_loss_weight * content_loss + style_loss_weight * style_loss

    return content_loss, style_loss, total_loss
# define the loss function

Model

In [0]:
def train(iteration=100, seed = 2019, show = False):
    tf.set_random_seed(seed)

    learning_rate = 2.0
    optimizer = tf.train.AdamOptimizer(learning_rate)
    training = optimizer.minimize(total_loss)

    sess = tf.InteractiveSession()
    sess.run(tf.global_variables_initializer())

    sess.run(input_img.assign(noise_images))

    for epoch in range(iteration): 

        sess.run(training)


        # generate a picture for every 20 epoches
        if epoch == 0 or (epoch+1) % 20 == 0:
            generated_image, total_losses = sess.run([input_img, total_loss])
            generated_image = generated_image + MEAN_PIXEL 

            print('Step' + str(epoch + 1) )
            print('Sum:' + str(np.sum(generated_image)))
            print('Loss:'+ str(total_losses))
            # save the picture
            path = '%s/%d_outputs/%d_seed/%s_relative_weight' % (style_name,
                                                                 iteration,
                                                                 seed,
                                                                 str(content_loss_weight))
            if not os.path.exists(path):
                os.makedirs(path)

            filename = '%s/%d_outputs/%d_seed/%s_relative_weight/epoch_%d.png' % (style_name,
                                                                       iteration,
                                                                       seed,
                                                                       str(content_loss_weight), 
                                                                       epoch+1)
            generated_image = generated_image[0]
            generated_image = np.clip(generated_image, 0, 255).astype('uint8')
            imageio.imwrite(filename, generated_image)

    if show == True:
        plt.imshow(generated_image)
        plt.axis('off')
# define the train function with seed 2019 and iteration 100 set by default

Test Result

In [0]:
content_path = 'drive/My Drive/5242_project/content5.jpg'
Image.open(content_path)
# input the content image
Out[0]:
In [0]:
style_path = 'drive/My Drive/5242_project/style2.jpg'
style_name = str(style_path.split("/")[-1].split(".")[0])
Image.open(style_path)
Out[0]:
In [0]:
image_width = 400
image_height = 300
MEAN_PIXEL = np.array([123.68, 116.779, 103.939]).reshape((1, 1, 1, 3))
style_image, content_image, noise_images = preprocess(content_path,style_path)
input_img = inp(image_width, image_height)
vgg = vgg_model(input_img)
# build Style & Content Representations
In [0]:
content_loss_weight = 0.001
style_loss_weight = 1
style_layers_weights = [0.5, 1.0, 1.5, 3.0, 4.0]
content_loss, style_loss, total_loss = losses()
# define the relevant weight and compute the loss

Results with Different Parameters

Iterations

Iteration = 100

In [0]:
train(iteration=100)
#training the model with 100 iterations
Step1
Sum:60014478.29682589
Loss:1434265100.0
Step20
Sum:59911156.08017684
Loss:275682430.0
Step40
Sum:59275205.80979617
Loss:150012290.0
Step60
Sum:58711892.95768114
Loss:110734216.0
Step80
Sum:58270991.83254014
Loss:94172540.0
Step100
Sum:57897140.668262206
Loss:85109810.0
In [0]:
path = 'style2/100_outputs/2019_seed/0.001_relative_weight/epoch_100.png'
Image.open(path)
Out[0]:

Iteration = 300

In [0]:
train(iteration=300)
#training the model with 300 iterations
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:60014478.29682589
Loss:1434265100.0
Step20
Sum:59911156.08017684
Loss:275682430.0
Step40
Sum:59275205.80979617
Loss:150012290.0
Step60
Sum:58711892.95768114
Loss:110734216.0
Step80
Sum:58270991.83254014
Loss:94172540.0
Step100
Sum:57897140.668262206
Loss:85109810.0
Step120
Sum:57560355.71748317
Loss:79199410.0
Step140
Sum:57246297.725738406
Loss:74854216.0
Step160
Sum:56947820.28429417
Loss:71447060.0
Step180
Sum:56660906.482850604
Loss:68702890.0
Step200
Sum:56383372.34748855
Loss:66425110.0
Step220
Sum:56113015.05647626
Loss:64477304.0
Step240
Sum:55848911.40763328
Loss:62765212.0
Step260
Sum:55589436.5667066
Loss:61225840.0
Step280
Sum:55333284.33515284
Loss:59826856.0
Step300
Sum:55080723.52520051
Loss:58546340.0
In [0]:
path = 'style2/300_outputs/2019_seed/0.001_relative_weight/epoch_300.png'
Image.open(path)
Out[0]:

Iteration = 500

In [0]:
train(iteration=500)
#training the model with 500 iterations
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:60014478.29682589
Loss:1434265100.0
Step20
Sum:59911156.08017684
Loss:275682430.0
Step40
Sum:59275205.80979617
Loss:150012290.0
Step60
Sum:58711892.95768114
Loss:110734216.0
Step80
Sum:58270991.83254014
Loss:94172540.0
Step100
Sum:57897140.668262206
Loss:85109810.0
Step120
Sum:57560355.71748317
Loss:79199410.0
Step140
Sum:57246297.725738406
Loss:74854216.0
Step160
Sum:56947820.28429417
Loss:71447060.0
Step180
Sum:56660906.482850604
Loss:68702890.0
Step200
Sum:56383372.34748855
Loss:66425110.0
Step220
Sum:56113015.05647626
Loss:64477304.0
Step240
Sum:55848911.40763328
Loss:62765212.0
Step260
Sum:55589436.5667066
Loss:61225840.0
Step280
Sum:55333284.33515284
Loss:59826856.0
Step300
Sum:55080723.52520051
Loss:58546340.0
Step320
Sum:54832264.309774764
Loss:57391360.0
Step340
Sum:54587275.07933508
Loss:56337576.0
Step360
Sum:54346316.59604735
Loss:55365160.0
Step380
Sum:54108649.92712682
Loss:54467360.0
Step400
Sum:53873690.42478287
Loss:53641990.0
Step420
Sum:53641338.88441858
Loss:52874510.0
Step440
Sum:53411781.37706701
Loss:52158710.0
Step460
Sum:53184180.310715206
Loss:51491216.0
Step480
Sum:52959033.504260525
Loss:50854760.0
Step500
Sum:52736903.01747667
Loss:50253910.0
In [0]:
path = 'style2/500_outputs/2019_seed/0.001_relative_weight/epoch_500.png'
Image.open(path)
Out[0]:

Iteration = 1000

In [0]:
train(iteration=1000)
#training the model with 1000 iterations
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:60014478.29682589
Loss:1434265100.0
Step20
Sum:59911156.08017684
Loss:275682430.0
Step40
Sum:59275205.80979617
Loss:150012290.0
Step60
Sum:58711892.95768114
Loss:110734216.0
Step80
Sum:58270991.83254014
Loss:94172540.0
Step100
Sum:57897140.668262206
Loss:85109810.0
Step120
Sum:57560355.71748317
Loss:79199410.0
Step140
Sum:57246297.725738406
Loss:74854216.0
Step160
Sum:56947820.28429417
Loss:71447060.0
Step180
Sum:56660906.482850604
Loss:68702890.0
Step200
Sum:56383372.34748855
Loss:66425110.0
Step220
Sum:56113015.05647626
Loss:64477304.0
Step240
Sum:55848911.40763328
Loss:62765212.0
Step260
Sum:55589436.5667066
Loss:61225840.0
Step280
Sum:55333284.33515284
Loss:59826856.0
Step300
Sum:55080723.52520051
Loss:58546340.0
Step320
Sum:54832264.309774764
Loss:57391360.0
Step340
Sum:54587275.07933508
Loss:56337576.0
Step360
Sum:54346316.59604735
Loss:55365160.0
Step380
Sum:54108649.92712682
Loss:54467360.0
Step400
Sum:53873690.42478287
Loss:53641990.0
Step420
Sum:53641338.88441858
Loss:52874510.0
Step440
Sum:53411781.37706701
Loss:52158710.0
Step460
Sum:53184180.310715206
Loss:51491216.0
Step480
Sum:52959033.504260525
Loss:50854760.0
Step500
Sum:52736903.01747667
Loss:50253910.0
Step520
Sum:52517543.77263653
Loss:49695704.0
Step540
Sum:52300374.752747916
Loss:49173376.0
Step560
Sum:52085651.3137337
Loss:48679210.0
Step580
Sum:51873808.330307364
Loss:48212616.0
Step600
Sum:51664667.28445208
Loss:47771470.0
Step620
Sum:51457918.912722565
Loss:47344580.0
Step640
Sum:51253346.36733363
Loss:46933710.0
Step660
Sum:51050957.545967355
Loss:46551948.0
Step680
Sum:50851630.25108908
Loss:46195460.0
Step700
Sum:50655002.73832254
Loss:45859916.0
Step720
Sum:50460198.82106131
Loss:45541940.0
Step740
Sum:50267568.5644173
Loss:45240544.0
Step760
Sum:50077036.41692572
Loss:44957160.0
Step780
Sum:49888600.25551714
Loss:44688520.0
Step800
Sum:49702693.79282365
Loss:44434124.0
Step820
Sum:49518884.338969246
Loss:44192216.0
Step840
Sum:49337162.09387705
Loss:43962120.0
Step860
Sum:49157616.84323455
Loss:43742576.0
Step880
Sum:48979740.14313947
Loss:43530730.0
Step900
Sum:48803366.57607669
Loss:43327908.0
Step920
Sum:48628750.01179661
Loss:43131640.0
Step940
Sum:48455993.09838222
Loss:42944344.0
Step960
Sum:48284866.828942604
Loss:42764524.0
Step980
Sum:48115040.7072588
Loss:42590600.0
Step1000
Sum:47946473.94412484
Loss:42422496.0
In [0]:
path = 'style2/1000_outputs/2019_seed/0.001_relative_weight/epoch_1000.png'
Image.open(path)
Out[0]:

Random Seeds

seed = 0

In [0]:
train(seed=0)
#training the model with seed 0
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:60014478.29682589
Loss:1434265100.0
Step20
Sum:59911156.08017684
Loss:275682430.0
Step40
Sum:59275205.80979617
Loss:150012290.0
Step60
Sum:58711892.95768114
Loss:110734216.0
Step80
Sum:58270991.83254014
Loss:94172540.0
Step100
Sum:57897140.668262206
Loss:85109810.0
In [0]:
path = 'style2/100_outputs/0_seed/0.001_relative_weight/epoch_100.png'
Image.open(path)
Out[0]:

seed = 2019

In [0]:
train(seed=2019)
#training the model with seed 2019
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:60014478.29682589
Loss:1434265100.0
Step20
Sum:59911156.08017684
Loss:275682430.0
Step40
Sum:59275205.80979617
Loss:150012290.0
Step60
Sum:58711892.95768114
Loss:110734216.0
Step80
Sum:58270991.83254014
Loss:94172540.0
Step100
Sum:57897140.668262206
Loss:85109810.0
In [0]:
path = 'style2/100_outputs/2019_seed/0.001_relative_weight/epoch_100.png'
Image.open(path)
Out[0]:

seed = 5242

In [0]:
train(seed = 5242)
#training the model with seed 5242 
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:60014478.29682589
Loss:1434265100.0
Step20
Sum:59911156.08017684
Loss:275682430.0
Step40
Sum:59275205.80979617
Loss:150012290.0
Step60
Sum:58711892.95768114
Loss:110734216.0
Step80
Sum:58270991.83254014
Loss:94172540.0
Step100
Sum:57897140.668262206
Loss:85109810.0
In [0]:
path = 'style2/100_outputs/5242_seed/0.001_relative_weight/epoch_100.png'
Image.open(path)
Out[0]:

Relative weights

relative_weight = 0.01

In [0]:
tf.reset_default_graph()
# content_path = 'drive/My Drive/42 Project/content.jpg'
# style_path = 'drive/My Drive/42 Project/style.jpg'
# content_path = 'drive/My Drive/content.jpg'
# style_path = 'drive/My Drive/style.jpg'
content_path = 'drive/My Drive/5242_project/content5.jpg'
style_path = 'drive/My Drive/5242_project/style2.jpg'
image_width = 400
image_height = 300

MEAN_PIXEL = np.array([123.68, 116.779, 103.939]).reshape((1, 1, 1, 3))

style_image, content_image, noise_images = preprocess(content_path,style_path)
input_img = inp(image_width, image_height)
vgg = vgg_model(input_img)

content_loss_weight = 0.01
style_loss_weight = 1
style_layers_weights = [0.5, 1.0, 1.5, 3.0, 4.0]
content_loss, style_loss, total_loss = losses()

train()
#training the model with 0.01, 0.001 relative weight 
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:60025123.47751344
Loss:1673701900.0
Step20
Sum:59970302.614153765
Loss:560597800.0
Step40
Sum:59369928.85115113
Loss:419361340.0
Step60
Sum:58777188.68279582
Loss:366921400.0
Step80
Sum:58233878.72538201
Loss:340410000.0
Step100
Sum:57714680.591651805
Loss:324253120.0
In [0]:
path = 'style2/100_outputs/2019_seed/0.01_relative_weight/epoch_100.png'
Image.open(path)
Out[0]:

relative_weight = 0.001

In [0]:
path = 'style2/100_outputs/2019_seed/0.001_relative_weight/epoch_100.png'
Image.open(path)
Out[0]:

relative_weight = 0.0001

In [0]:
tf.reset_default_graph()
content_path = 'drive/My Drive/5242_project/content5.jpg'
style_path = 'drive/My Drive/5242_project/style2.jpg'
image_width = 400
image_height = 300

MEAN_PIXEL = np.array([123.68, 116.779, 103.939]).reshape((1, 1, 1, 3))

style_image, content_image, noise_images = preprocess(content_path,style_path)
input_img = inp(image_width, image_height)
vgg = vgg_model(input_img)

content_loss_weight = 0.0001
style_loss_weight = 1
style_layers_weights = [0.5, 1.0, 1.5, 3.0, 4.0]
content_loss, style_loss, total_loss = losses()

train()
#training the model with 0.0001 relative weight 
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:60017997.3806603
Loss:1418520000.0
Step20
Sum:59909926.33641858
Loss:236611410.0
Step40
Sum:59284792.3961171
Loss:107484280.0
Step60
Sum:58723465.69696828
Loss:67261730.0
Step80
Sum:58289584.45354377
Loss:50617160.0
Step100
Sum:57933751.48742826
Loss:41776810.0
In [0]:
path = 'style2/100_outputs/2019_seed/0.0001_relative_weight/epoch_100.png'
Image.open(path)
Out[0]:

After parameter tuning process, we decide to use our model with 1000 iterations, 0.0001 relative weights and 2019 (default) seed.

Final Model Training

Overlay Van Gogh on temple

In [32]:
tf.reset_default_graph()
content_path = 'drive/My Drive/5242_project/content5.jpg'
style_path = 'drive/My Drive/5242_project/style2.jpg'
image_width = 400
image_height = 300

MEAN_PIXEL = np.array([123.68, 116.779, 103.939]).reshape((1, 1, 1, 3))

style_image, content_image, noise_images = preprocess(content_path,style_path)
input_img = inp(image_width, image_height)
vgg = vgg_model(input_img)

content_loss_weight = 0.0001
style_loss_weight = 1
style_layers_weights = [0.5, 1.0, 1.5, 3.0, 4.0]
content_loss, style_loss, total_loss = losses()

train(iteration = 1000)
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:60012913.81102491
Loss:1408605700.0
Step20
Sum:59905378.17859862
Loss:235652740.0
Step40
Sum:59276494.75089334
Loss:107450744.0
Step60
Sum:58713861.09469623
Loss:68012140.0
Step80
Sum:58272319.25750565
Loss:51195024.0
Step100
Sum:57909731.05774207
Loss:42226080.0
Step120
Sum:57595397.31462461
Loss:36606290.0
Step140
Sum:57311051.85492168
Loss:32713308.0
Step160
Sum:57046964.613338985
Loss:29810758.0
Step180
Sum:56798064.19974204
Loss:27528572.0
Step200
Sum:56560638.54991041
Loss:25664568.0
Step220
Sum:56331583.44415894
Loss:24097492.0
Step240
Sum:56109465.34378114
Loss:22754340.0
Step260
Sum:55893629.93201331
Loss:21601598.0
Step280
Sum:55683613.496024646
Loss:20588112.0
Step300
Sum:55479150.23423982
Loss:19677492.0
Step320
Sum:55279074.13227819
Loss:18850660.0
Step340
Sum:55083409.61322937
Loss:18108350.0
Step360
Sum:54891807.72484443
Loss:17454888.0
Step380
Sum:54704117.17722596
Loss:16867996.0
Step400
Sum:54520374.676961996
Loss:16334435.0
Step420
Sum:54340277.5104032
Loss:15842008.0
Step440
Sum:54163491.776505865
Loss:15388054.0
Step460
Sum:53989116.0271316
Loss:14969571.0
Step480
Sum:53817634.26567511
Loss:14581233.0
Step500
Sum:53648324.83741705
Loss:14217458.0
Step520
Sum:53481136.61028829
Loss:13876878.0
Step540
Sum:53315671.4496524
Loss:13556509.0
Step560
Sum:53151714.20862845
Loss:13254004.0
Step580
Sum:52989225.404732935
Loss:12968626.0
Step600
Sum:52828583.939120054
Loss:12699768.0
Step620
Sum:52669504.700752035
Loss:12449229.0
Step640
Sum:52511989.25367231
Loss:12212558.0
Step660
Sum:52355954.70333778
Loss:11985032.0
Step680
Sum:52201188.72964855
Loss:11766960.0
Step700
Sum:52047714.913035505
Loss:11557477.0
Step720
Sum:51895398.581507355
Loss:11357448.0
Step740
Sum:51744626.89127037
Loss:11166997.0
Step760
Sum:51595456.11855376
Loss:10987298.0
Step780
Sum:51447384.05906084
Loss:10815772.0
Step800
Sum:51300520.32320801
Loss:10650319.0
Step820
Sum:51154608.940487124
Loss:10490688.0
Step840
Sum:51009892.97183346
Loss:10338172.0
Step860
Sum:50866613.00107819
Loss:10192554.0
Step880
Sum:50724619.66751067
Loss:10053663.0
Step900
Sum:50583615.59216686
Loss:9920706.0
Step920
Sum:50443880.82328398
Loss:9794136.0
Step940
Sum:50304987.18608505
Loss:9673136.0
Step960
Sum:50166713.02941241
Loss:9556202.0
Step980
Sum:50029235.045310624
Loss:9444984.0
Step1000
Sum:49892761.99372962
Loss:9338092.0
In [7]:
path = 'style2/1000_outputs/2019_seed/0.0001_relative_weight/epoch_1000.png'
Image.open(path)
Out[7]:

Overlay Van Gogh on cafe

In [0]:
tf.reset_default_graph()
content_path = 'drive/My Drive/5242_project/content2.jpg'
style_path = 'drive/My Drive/5242_project/style2.jpg'
image_width = 400
image_height = 300

MEAN_PIXEL = np.array([123.68, 116.779, 103.939]).reshape((1, 1, 1, 3))

style_image, content_image, noise_images = preprocess(content_path,style_path)
input_img = inp(image_width, image_height)
vgg = vgg_model(input_img)

content_loss_weight = 0.0001
style_loss_weight = 1
style_layers_weights = [0.5, 1.0, 1.5, 3.0, 4.0]
content_loss, style_loss, total_loss = losses()

train(iteration = 1000)
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:57683054.585107215
Loss:2109910900.0
Step20
Sum:57933884.44047715
Loss:389840580.0
Step40
Sum:57530486.26836825
Loss:173254540.0
Step60
Sum:57005053.55325004
Loss:102580700.0
Step80
Sum:56556254.49071848
Loss:71881300.0
Step100
Sum:56180626.47637906
Loss:55549636.0
Step120
Sum:55860009.21374713
Loss:45528060.0
Step140
Sum:55578896.34351999
Loss:38733200.0
Step160
Sum:55327044.68470176
Loss:33844076.0
Step180
Sum:55099469.91524908
Loss:30177752.0
Step200
Sum:54890925.4665911
Loss:27343658.0
Step220
Sum:54696209.64907634
Loss:25089594.0
Step240
Sum:54513169.566676885
Loss:23244718.0
Step260
Sum:54339319.60152421
Loss:21711136.0
Step280
Sum:54172637.99050363
Loss:20408916.0
Step300
Sum:54012414.31912854
Loss:19290410.0
Step320
Sum:53856986.85420873
Loss:18310770.0
Step340
Sum:53706094.80065158
Loss:17445838.0
Step360
Sum:53558269.77843223
Loss:16680444.0
Step380
Sum:53413278.705410235
Loss:16004526.0
Step400
Sum:53270495.0531832
Loss:15395608.0
Step420
Sum:53129514.74913101
Loss:14841650.0
Step440
Sum:52990231.461865164
Loss:14337063.0
Step460
Sum:52852378.85138407
Loss:13876722.0
Step480
Sum:52715776.344470255
Loss:13453980.0
Step500
Sum:52580079.786718756
Loss:13063560.0
Step520
Sum:52445651.71406315
Loss:12703436.0
Step540
Sum:52312056.278248794
Loss:12368902.0
Step560
Sum:52179076.61569655
Loss:12057246.0
Step580
Sum:52046831.84717872
Loss:11765854.0
Step600
Sum:51915394.36743052
Loss:11491544.0
Step620
Sum:51784610.71307232
Loss:11235490.0
Step640
Sum:51654434.27196913
Loss:10996302.0
Step660
Sum:51524963.30489534
Loss:10773738.0
Step680
Sum:51396372.51992731
Loss:10565278.0
Step700
Sum:51268465.31706552
Loss:10367481.0
Step720
Sum:51141345.54625156
Loss:10179882.0
Step740
Sum:51014749.833977304
Loss:10000838.0
Step760
Sum:50888642.72443492
Loss:9829620.0
Step780
Sum:50763180.185781896
Loss:9667202.0
Step800
Sum:50638167.94038596
Loss:9512328.0
Step820
Sum:50513457.60409458
Loss:9364390.0
Step840
Sum:50389209.32456774
Loss:9223163.0
Step860
Sum:50265367.070167884
Loss:9087694.0
Step880
Sum:50142077.50005162
Loss:8958358.0
Step900
Sum:50019383.55633469
Loss:8834854.0
Step920
Sum:49897294.48779052
Loss:8716017.0
Step940
Sum:49775672.22146361
Loss:8601829.0
Step960
Sum:49654924.437630214
Loss:8492306.0
Step980
Sum:49534918.60212895
Loss:8386888.0
Step1000
Sum:49415427.805123396
Loss:8285632.0
In [8]:
path = 'style2/1000_outputs/2019_seed/0.0001_relative_weight/epoch_1000.png'
Image.open(path)
Out[8]:

Overlay Van Gogh on One Piece

In [0]:
tf.reset_default_graph()
content_path = 'drive/My Drive/5242_project/content10.jpg'
style_path = 'drive/My Drive/5242_project/style2.jpg'
image_width = 400
image_height = 300

MEAN_PIXEL = np.array([123.68, 116.779, 103.939]).reshape((1, 1, 1, 3))

style_image, content_image, noise_images = preprocess(content_path,style_path)
input_img = inp(image_width, image_height)
vgg = vgg_model(input_img)

content_loss_weight = 0.0001
style_loss_weight = 1
style_layers_weights = [0.5, 1.0, 1.5, 3.0, 4.0]
content_loss, style_loss, total_loss = losses()

train(iteration = 1000)
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:63234265.63775433
Loss:1471033000.0
Step20
Sum:63190770.524300605
Loss:358813340.0
Step40
Sum:62652247.570986554
Loss:179189010.0
Step60
Sum:62051311.91293563
Loss:114224344.0
Step80
Sum:61507550.99152515
Loss:83914510.0
Step100
Sum:61023073.98723159
Loss:66746370.0
Step120
Sum:60588066.53598951
Loss:55646100.0
Step140
Sum:60194771.216030724
Loss:47808530.0
Step160
Sum:59836216.739683114
Loss:42040916.0
Step180
Sum:59505940.69753065
Loss:37639556.0
Step200
Sum:59199685.79657351
Loss:34102700.0
Step220
Sum:58913798.021451734
Loss:31229020.0
Step240
Sum:58644804.592490226
Loss:28862778.0
Step260
Sum:58390111.9951172
Loss:26894598.0
Step280
Sum:58147461.27771061
Loss:25226264.0
Step300
Sum:57914860.28283078
Loss:23792450.0
Step320
Sum:57690417.883967414
Loss:22539662.0
Step340
Sum:57473418.23722464
Loss:21434736.0
Step360
Sum:57263198.92301447
Loss:20463394.0
Step380
Sum:57058561.62760563
Loss:19594278.0
Step400
Sum:56858202.94241545
Loss:18808276.0
Step420
Sum:56661624.53870675
Loss:18086652.0
Step440
Sum:56468601.81684695
Loss:17429130.0
Step460
Sum:56278921.90987793
Loss:16832032.0
Step480
Sum:56091843.69910942
Loss:16289960.0
Step500
Sum:55907258.64412969
Loss:15795374.0
Step520
Sum:55724850.85283174
Loss:15342372.0
Step540
Sum:55544343.01663155
Loss:14924462.0
Step560
Sum:55366146.54546563
Loss:14536528.0
Step580
Sum:55189618.36336593
Loss:14172534.0
Step600
Sum:55014805.8609145
Loss:13830434.0
Step620
Sum:54841210.26334746
Loss:13505819.0
Step640
Sum:54668904.90800731
Loss:13200129.0
Step660
Sum:54497824.12402814
Loss:12910366.0
Step680
Sum:54328155.03091892
Loss:12632889.0
Step700
Sum:54159921.05681848
Loss:12369650.0
Step720
Sum:53993175.40588378
Loss:12121944.0
Step740
Sum:53827739.633510366
Loss:11888078.0
Step760
Sum:53663532.44380545
Loss:11666199.0
Step780
Sum:53500331.00382632
Loss:11453447.0
Step800
Sum:53337836.21171992
Loss:11248918.0
Step820
Sum:53176308.01329953
Loss:11051870.0
Step840
Sum:53015750.540542364
Loss:10864808.0
Step860
Sum:52856314.2814469
Loss:10685886.0
Step880
Sum:52698004.009987675
Loss:10514364.0
Step900
Sum:52540737.908189
Loss:10351148.0
Step920
Sum:52384403.898915455
Loss:10194804.0
Step940
Sum:52229125.14791097
Loss:10044244.0
Step960
Sum:52074689.80920054
Loss:9899140.0
Step980
Sum:51920990.99318809
Loss:9759506.0
Step1000
Sum:51768407.6220783
Loss:9624684.0
In [9]:
path = 'style2/1000_outputs/2019_seed/0.0001_relative_weight/epoch_1000.png'
Image.open(path)
Out[9]:

Overlay Picasso on temple

In [26]:
tf.reset_default_graph()
content_path = 'drive/My Drive/5242_project/content5.jpg'
style_path = 'drive/My Drive/5242_project/style5.jpg'
style_name = str(style_path.split("/")[-1].split(".")[0])

image_width = 400
image_height = 300

MEAN_PIXEL = np.array([123.68, 116.779, 103.939]).reshape((1, 1, 1, 3))

style_image, content_image, noise_images = preprocess(content_path,style_path)
input_img = inp(image_width, image_height)
vgg = vgg_model(input_img)

content_loss_weight = 0.0001
style_loss_weight = 1
style_layers_weights = [0.5, 1.0, 1.5, 3.0, 4.0]
content_loss, style_loss, total_loss = losses()

train(iteration=1000)
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:60023230.48713852
Loss:7282116600.0
Step20
Sum:60202162.740036555
Loss:1681315500.0
Step40
Sum:59605277.96864204
Loss:751686500.0
Step60
Sum:59055046.286741495
Loss:455177860.0
Step80
Sum:58631550.096783176
Loss:314759170.0
Step100
Sum:58291843.61232536
Loss:236138850.0
Step120
Sum:58001647.52223118
Loss:186563740.0
Step140
Sum:57743324.35363633
Loss:153262160.0
Step160
Sum:57507280.94916011
Loss:130035300.0
Step180
Sum:57286477.312741525
Loss:113245880.0
Step200
Sum:57078208.4123522
Loss:100690020.0
Step220
Sum:56879810.30214782
Loss:90975630.0
Step240
Sum:56689443.30240968
Loss:83238904.0
Step260
Sum:56506185.788881436
Loss:76983450.0
Step280
Sum:56329312.06009266
Loss:71809260.0
Step300
Sum:56157813.328660525
Loss:67433990.0
Step320
Sum:55991031.473155245
Loss:63690816.0
Step340
Sum:55827588.2878153
Loss:60425690.0
Step360
Sum:55667105.709744416
Loss:57547370.0
Step380
Sum:55510199.98840075
Loss:54965630.0
Step400
Sum:55356337.30399538
Loss:52628790.0
Step420
Sum:55204629.44940515
Loss:50524460.0
Step440
Sum:55055152.14856989
Loss:48625716.0
Step460
Sum:54908020.50920094
Loss:46904310.0
Step480
Sum:54762878.68864452
Loss:45331080.0
Step500
Sum:54619160.18249491
Loss:43892396.0
Step520
Sum:54477010.54951295
Loss:42572810.0
Step540
Sum:54336090.10957206
Loss:41351930.0
Step560
Sum:54196422.38509711
Loss:40220668.0
Step580
Sum:54057685.29630469
Loss:39159024.0
Step600
Sum:53919869.694558166
Loss:38156850.0
Step620
Sum:53782998.88175281
Loss:37213190.0
Step640
Sum:53647055.988810994
Loss:36322970.0
Step660
Sum:53511931.75210165
Loss:35475476.0
Step680
Sum:53377697.011347145
Loss:34668932.0
Step700
Sum:53244477.03091943
Loss:33902730.0
Step720
Sum:53112085.07367134
Loss:33175060.0
Step740
Sum:52980457.57415081
Loss:32482660.0
Step760
Sum:52849620.69896332
Loss:31823728.0
Step780
Sum:52719560.92002689
Loss:31196398.0
Step800
Sum:52590015.15159571
Loss:30599852.0
Step820
Sum:52461198.15195401
Loss:30032276.0
Step840
Sum:52333067.57649183
Loss:29493130.0
Step860
Sum:52205790.76422866
Loss:28976984.0
Step880
Sum:52079378.348360315
Loss:28479560.0
Step900
Sum:51953448.59050081
Loss:28002578.0
Step920
Sum:51828132.914477006
Loss:27545502.0
Step940
Sum:51703502.98517102
Loss:27106182.0
Step960
Sum:51579481.08271606
Loss:26683612.0
Step980
Sum:51456311.97505389
Loss:26275610.0
Step1000
Sum:51333769.3666525
Loss:25881544.0
In [12]:
path = 'style5/1000_outputs/2019_seed/0.0001_relative_weight/epoch_1000.png'
Image.open(path)
Out[12]:

Overlay Picasso on cafe

In [28]:
tf.reset_default_graph()
content_path = 'drive/My Drive/5242_project/content2.jpg'
style_path = 'drive/My Drive/5242_project/style5.jpg'
style_name = str(style_path.split("/")[-1].split(".")[0])

image_width = 400
image_height = 300

MEAN_PIXEL = np.array([123.68, 116.779, 103.939]).reshape((1, 1, 1, 3))

style_image, content_image, noise_images = preprocess(content_path,style_path)
input_img = inp(image_width, image_height)
vgg = vgg_model(input_img)

content_loss_weight = 0.0001
style_loss_weight = 1
style_layers_weights = [0.5, 1.0, 1.5, 3.0, 4.0]
content_loss, style_loss, total_loss = losses()

train(iteration=1000)
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:57693735.95274008
Loss:7836742700.0
Step20
Sum:58023761.82689807
Loss:1821582800.0
Step40
Sum:57485062.91911922
Loss:748699970.0
Step60
Sum:56916353.86604656
Loss:459742180.0
Step80
Sum:56479471.05103006
Loss:322696960.0
Step100
Sum:56132015.7075878
Loss:243200740.0
Step120
Sum:55838557.651474796
Loss:192399470.0
Step140
Sum:55582145.60489195
Loss:157794640.0
Step160
Sum:55352595.570161104
Loss:133079544.0
Step180
Sum:55144221.97954762
Loss:115100400.0
Step200
Sum:54952012.09165913
Loss:101460250.0
Step220
Sum:54771739.66433659
Loss:90911144.0
Step240
Sum:54600628.73158501
Loss:82546580.0
Step260
Sum:54436348.51911117
Loss:75777430.0
Step280
Sum:54277137.94482249
Loss:70229600.0
Step300
Sum:54122092.61969668
Loss:65589136.0
Step320
Sum:53970918.7065537
Loss:61648148.0
Step340
Sum:53823026.427306265
Loss:58265108.0
Step360
Sum:53677996.6711398
Loss:55306190.0
Step380
Sum:53535383.93288922
Loss:52687260.0
Step400
Sum:53394902.08971571
Loss:50385424.0
Step420
Sum:53256507.633227654
Loss:48319844.0
Step440
Sum:53119810.7095755
Loss:46445670.0
Step460
Sum:52984348.6364318
Loss:44731388.0
Step480
Sum:52850359.75150196
Loss:43162310.0
Step500
Sum:52717802.563452415
Loss:41727096.0
Step520
Sum:52586132.96150597
Loss:40404030.0
Step540
Sum:52455263.535235964
Loss:39169184.0
Step560
Sum:52325081.473387495
Loss:38014190.0
Step580
Sum:52195504.057839006
Loss:36938084.0
Step600
Sum:52066811.05414499
Loss:35927224.0
Step620
Sum:51939038.181641504
Loss:34973384.0
Step640
Sum:51812502.983906105
Loss:34074010.0
Step660
Sum:51686921.37893588
Loss:33217218.0
Step680
Sum:51562269.5513628
Loss:32404980.0
Step700
Sum:51438394.746077366
Loss:31633558.0
Step720
Sum:51315628.94683486
Loss:30899416.0
Step740
Sum:51193678.05554635
Loss:30199890.0
Step760
Sum:51072486.90313456
Loss:29534592.0
Step780
Sum:50952297.04554731
Loss:28903820.0
Step800
Sum:50832984.47376798
Loss:28304242.0
Step820
Sum:50714825.91883009
Loss:27730232.0
Step840
Sum:50597464.961937
Loss:27182864.0
Step860
Sum:50481118.152917154
Loss:26660350.0
Step880
Sum:50365811.01075169
Loss:26163580.0
Step900
Sum:50251210.88021035
Loss:25687446.0
Step920
Sum:50137407.9259366
Loss:25229610.0
Step940
Sum:50024406.027017206
Loss:24790952.0
Step960
Sum:49912131.594407275
Loss:24368972.0
Step980
Sum:49800649.209489726
Loss:23965562.0
Step1000
Sum:49689902.92047995
Loss:23579396.0
In [11]:
path = 'style5/1000_outputs/2019_seed/0.0001_relative_weight/epoch_1000.png'
Image.open(path)
Out[11]:

Overlay Picasso on One Piece

In [30]:
tf.reset_default_graph()
content_path = 'drive/My Drive/5242_project/content10.jpg'
style_path = 'drive/My Drive/5242_project/style5.jpg'
style_name = str(style_path.split("/")[-1].split(".")[0])

image_width = 400
image_height = 300

MEAN_PIXEL = np.array([123.68, 116.779, 103.939]).reshape((1, 1, 1, 3))

style_image, content_image, noise_images = preprocess(content_path,style_path)
input_img = inp(image_width, image_height)
vgg = vgg_model(input_img)

content_loss_weight = 0.0001
style_loss_weight = 1
style_layers_weights = [0.5, 1.0, 1.5, 3.0, 4.0]
content_loss, style_loss, total_loss = losses()

train(iteration=1000)
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py:1750: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
  warnings.warn('An interactive session is already active. This can '
Step1
Sum:63243365.75396145
Loss:6168966700.0
Step20
Sum:63192945.60395221
Loss:1170448300.0
Step40
Sum:62502588.35968322
Loss:537265700.0
Step60
Sum:61927561.28485711
Loss:328041700.0
Step80
Sum:61473344.65583627
Loss:232960110.0
Step100
Sum:61094735.978735
Loss:180049600.0
Step120
Sum:60765465.67397017
Loss:146750640.0
Step140
Sum:60468042.34302052
Loss:124240520.0
Step160
Sum:60191470.41019772
Loss:108176290.0
Step180
Sum:59932689.0960939
Loss:96364360.0
Step200
Sum:59687168.76058258
Loss:87316670.0
Step220
Sum:59451727.069684215
Loss:80128700.0
Step240
Sum:59224590.77558684
Loss:74197240.0
Step260
Sum:59004407.43330747
Loss:69225800.0
Step280
Sum:58790359.92864054
Loss:65008148.0
Step300
Sum:58581647.733494535
Loss:61363280.0
Step320
Sum:58377736.93370645
Loss:58193040.0
Step340
Sum:58177977.2356568
Loss:55413064.0
Step360
Sum:57981454.07970563
Loss:52932870.0
Step380
Sum:57787414.68258423
Loss:50683896.0
Step400
Sum:57595911.72579792
Loss:48634860.0
Step420
Sum:57406967.85073431
Loss:46765816.0
Step440
Sum:57220629.41971832
Loss:45055110.0
Step460
Sum:57036725.45174508
Loss:43484308.0
Step480
Sum:56855125.13782157
Loss:42036744.0
Step500
Sum:56675507.930703886
Loss:40693508.0
Step520
Sum:56497725.806728974
Loss:39439316.0
Step540
Sum:56321754.34888421
Loss:38270944.0
Step560
Sum:56147266.32556459
Loss:37176230.0
Step580
Sum:55974343.16533683
Loss:36144836.0
Step600
Sum:55802675.70936869
Loss:35173270.0
Step620
Sum:55632119.13855663
Loss:34254184.0
Step640
Sum:55462931.932706036
Loss:33392210.0
Step660
Sum:55295089.55433448
Loss:32577348.0
Step680
Sum:55128616.471064
Loss:31803972.0
Step700
Sum:54963382.54630153
Loss:31073108.0
Step720
Sum:54799207.142853595
Loss:30378636.0
Step740
Sum:54636373.97011017
Loss:29715138.0
Step760
Sum:54474772.57300374
Loss:29080476.0
Step780
Sum:54314380.45174326
Loss:28473876.0
Step800
Sum:54154996.647387065
Loss:27898328.0
Step820
Sum:53996765.69223329
Loss:27349818.0
Step840
Sum:53839648.21059021
Loss:26823900.0
Step860
Sum:53683482.00383615
Loss:26320466.0
Step880
Sum:53528366.056527935
Loss:25839438.0
Step900
Sum:53374178.50684695
Loss:25377682.0
Step920
Sum:53220901.768139414
Loss:24932272.0
Step940
Sum:53068489.255071625
Loss:24502904.0
Step960
Sum:52917071.13074628
Loss:24087138.0
Step980
Sum:52766706.04455644
Loss:23684702.0
Step1000
Sum:52617462.865485005
Loss:23294976.0
In [10]:
path = 'style5/1000_outputs/2019_seed/0.0001_relative_weight/epoch_1000.png'
Image.open(path)
Out[10]: